<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
    window.onload = function (){
      var imgObj = document.getElementById("moveImg");

      //e表示事件对象，记录了事件发生时的信息
      //鼠标移动事件
      document.onmousemove= function (e){
        //得到鼠标的X坐标
          imgObj.style.left = e.clientX+ 10 + "px";
          imgObj.style.top = e.clientY + 10 + "px";
      }
      //鼠标进入事件
      document.onmouseover = function (){
        imgObj.style.display = "block";
      }
      //鼠标离开事件
      document.onmouseout = function (){
        imgObj.style.display = "none";
      }
    }
  </script>
</head>
<body>
  <img src="photo/g1.jpg" style="position: absolute;display: none" id="moveImg">
</body>
</html>
